<?php

namespace app\admin\validate;

use think\Validate;

class Image extends  Validate
{
    protected $rule = [
        'file_type' => ['in'=>'image/png,image/jpeg'],
        'file_size' => 'validateImageSize'
    ];

    protected $message = [
        'file_type.in' => '图片类型不符合',
    ];

    protected function validateImageSize($value, $rule, $data = [])
    {

        $MAX_SIZE = 600 * 1024;

        if ($value > $MAX_SIZE) {
            return '文件太大,请上传不超过600k的文件';
        }
        return true;
    }
}
